package com.ry.widget;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.webkit.ValueCallback;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    Handler mh = new Handler();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final MyRippleView rippleLayout = findViewById(R.id.MyRippleLayout);

        mh.postDelayed(new Runnable() {
            @Override
            public void run() {
                rippleLayout.stopAnimator();
                Toast.makeText(MainActivity.this, "动画退出", Toast.LENGTH_SHORT).show();
            }
        },50000);



        final MyRippleWidthProgressView MyRipple_progress = findViewById(R.id.MyRipple_progress);
        MyRipple_progress.setOnClickListener(new View.OnClickListener() {
            boolean flag = false;
            @Override
            public void onClick(View v) {
                if(!flag) {
                    MyRipple_progress.startAnimator();
                    flag = true;
                }else{
                    MyRipple_progress.reset();
                    flag = false;
                }
            }
        });

//        MyRipple_progress.setTotalSeconds(5);
        MyRipple_progress.setProgressCallback(new ValueCallback<Integer>() {
            int flag = -1;
            @Override
            public void onReceiveValue(Integer value) {
                if(value != flag) {
                    Log.d("RXZ", /*String.valueOf(value)+*/"=" + value);
                    flag = value;
                }
            }
        });

        final MyHorizontalProgressBar myHorizontalProgressBar  = findViewById(R.id.MyHorizontalProgressBar);
        myHorizontalProgressBar.setBorderColor(Color.TRANSPARENT);
        myHorizontalProgressBar.setRadius(0);
        myHorizontalProgressBar.setBackgroundColor(Color.argb(0xff * 20 / 100,0xff,0x68,0x9a));
        myHorizontalProgressBar.setProgress(10,10, Color.argb(0xff,0xff,0x68,0x9a),true,30);
    }

}